package com.example.smartcity.ui.smartCity.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.smartcity.R
import com.example.smartcity.ui.smartCity.Adapter.SmRecyclerViewAdapter
import com.example.smartcity.ui.smartCity.model.Sm

class SmFragment_1 : Fragment() {
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val root = inflater.inflate(R.layout.fragment_sm_1, container, false)


        val re = root.findViewById<RecyclerView>(R.id.SmRecyclerView1)
        val array = ArrayList<Sm>()
        for (i in 1..20){
            array.add(Sm(
                "文章标题$i",
                "文章内容标题$i",
                "2023.1.1"
            ))
        }

        // 设置RecyclerView适配器
        val layout = LinearLayoutManager(context)
        re.layoutManager = layout
        val adapter = SmRecyclerViewAdapter(array)
        re.adapter = adapter


        return root
    }

}